nlp_architect.models.intent_extraction.Seq2SeqIntentModel

class nlp_architect.models.intent_extraction.Seq2SeqIntentModel[source]

Encoder Decoder Deep LSTM Tagger Model (using tf.keras)

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__() Initialize self.
build(vocab_size, tag_labels[, …]) Build the model
fit(x, y[, epochs, batch_size, callbacks, …]) Train a model given input samples and target labels.
load(path) Load a trained model
load_embedding_weights(weights) Load word embedding weights into the model embedding layer
predict(x[, batch_size]) Get the prediction of the model on given input
save(path[, exclude]) Save model to path

Attributes

input_shape Get input shape
build(vocab_size, tag_labels, token_emb_size=100, encoder_depth=1, decoder_depth=1, lstm_hidden_size=100, encoder_dropout=0.5, decoder_dropout=0.5)[source]

Build the model

Parameters:
  • vocab_size (int) – vocabulary size
  • tag_labels (int) – number of tag labels
  • token_emb_size (int, optional) – token embedding vector size
  • encoder_depth (int, optional) – number of encoder LSTM layers
  • decoder_depth (int, optional) – number of decoder LSTM layers
  • lstm_hidden_size (int, optional) – LSTM layers hidden size
  • encoder_dropout (float, optional) – encoder dropout
  • decoder_dropout (float, optional) – decoder dropout
fit(x, y, epochs=1, batch_size=1, callbacks=None, validation=None)

Train a model given input samples and target labels.

Parameters:
  • x – input samples
  • y – input sample labels
  • epochs (int, optional) – number of epochs to train
  • batch_size (int, optional) – batch size
  • callbacks (Callback, optional) – Keras compatible callbacks
  • validation (list of numpy.ndarray, optional) – optional validation data to be evaluated when training
input_shape

Get input shape

Type:tuple
load(path)

Load a trained model

Parameters:path (str) – path to model file
load_embedding_weights(weights)

Load word embedding weights into the model embedding layer

Parameters:weights (numpy.ndarray) – 2D matrix of word weights
predict(x, batch_size=1)

Get the prediction of the model on given input

Parameters:
  • x – samples to run through the model
  • batch_size (int, optional) – batch size:
Returns:

predicted values by the model

Return type:

numpy.ndarray

save(path, exclude=None)

Save model to path

Parameters:
  • path (str) – path to save model
  • exclude (list, optional) – a list of object fields to exclude when saving